﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Icedream.InstantFileTransfer;

namespace TestClient
{
    class Program
    {
        static void Main(string[] args)
        {
            IFTPClient cl = new IFTPClient();

            Console.WriteLine("IFTP Test Client");
            Console.WriteLine();
            Console.Write("IP/Host: ");
            string host = Console.ReadLine();

            Console.Write("Connecting... ");
            cl.Connect(host, IFTPServer.StandardPort);
            Console.WriteLine("OK!");
            Console.Write("Doing test... ");
            cl.DoTest();
            Console.WriteLine("OK!");
            Console.Write("Disconnecting... ");
            cl.Quit("Test only");
            Console.WriteLine("OK!");
            Console.WriteLine();

            Console.WriteLine("Test size:\t" + GetSize(cl.LastTestSize));
            Console.WriteLine("Test length:\t" + cl.LastTestTime.ToString());

            Console.WriteLine("====");
            Console.WriteLine(GetSize(cl.LastTestSize / cl.LastTestTime.TotalSeconds) + "/s");

            Console.ReadLine();
        }

        static readonly string[] units = { "Bytes", "kB", "MB", "GB", "TB", "EB", "PB" };
        static string GetSize(double size)
        {
            int i = 0;
            while (size > 1024)
            {
                i++;
                size /= 1024;
            }
            return size.ToString() + " " + units[i];
        }
    }
}
